import {createStore, applyMiddleware} from 'redux';
import reducer from './reducer';
import createSagaMiddleware from '../redux-saga';
import rootSaga from './sagas';

//用户可以在此传参
const sagaMiddleware = createSagaMiddleware();
//sagaMiddleware就是我们的进程管理器
//一旦你使用了sagaMiddleware这个中间件后, store.dispatch指向的就是sagaMiddleware提供的dispatch方法了
const store = applyMiddleware(sagaMiddleware)(createStore)(reducer);
//启动一个saga执行
sagaMiddleware.run(rootSaga);

export default store;
